/*


//第一题
*/
/*public class Zuoxiaofeng202313840227 {
    public static void main(String[] args) {
        System.out.println("    "+"木兰花·拟古决绝词柬友"+"    ");
        System.out.println("                 "+"清代·纳兰性德");
        System.out.println("       "+"人生若只如初见，"+"       ");
        System.out.println("       "+"何事秋风悲画扇。"+"       ");
        System.out.println("       "+"等闲变却故人心，"+"       ");
        System.out.println("       "+"却道故人心易变。"+"       ");
        System.out.println("       "+"骊山语罢清宵半，"+"       ");
        System.out.println("       "+"泪雨霖铃终不怨。"+"       ");
        System.out.println("       "+"何如薄幸锦衣郎，"+"       ");
        System.out.println("       "+"比翼连枝当日愿。"+"       ");
    }
}*//*




//第二题
import java.math.BigInteger;
import java.util.Scanner;
    public class Zuoxiaofeng202313840227 {
        public static BigInteger jc(int n) {
            BigInteger num = new BigInteger("1");
            */
/*//*
/for循环实现
            for(int i = 2; i <= n; i++) {
                num = num.multiply(new BigInteger(Integer.toString(i)));
            }*//*


            //while循环实现
            int i = 2;
            while(i <= n) {
                num = num.multiply(new BigInteger((Integer.toString(i))));
                i++;
            }
            return num;
        }
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            int n = scan.nextInt();
            if(n >= 1 && n <= 100) {
                BigInteger sum = new BigInteger("0");
                //for循环实现
                */
/*for (int i = 1; i <= n; i++) {
                    sum = sum.add(jc(i));
                }*//*

                //while循环实现
                int i = 0;
                while(i <= n) {
                    sum = sum.add(jc(i));
                    i++;
                }
                System.out.println(sum);
            } else {
                return;
            }
        }
    }
*/


import java.util.Random;
import java.util.Scanner;

public class caller {
    /**

     * 1.存储全班同学姓名 创建一个存储多个同学姓名的容器（数组） 键盘输入每个同学的姓名，存储到容器中（数组）

     */

    public static void addStudentName(String[] students) {

        // 键盘输入多个同学姓名存储到容器中

        Scanner sc = new Scanner(System.in);

        for (int i = 0; i < students.length; i++) {

            System.out.println("存储第" + (i + 1) + "个姓名：");

            // 接收控制台录入的姓名字符串

            students[i] = sc.next();

        }

    }



    /**

     * 2.总览全班同学姓名

     */

    public static void printStudentName(String[] students) {

        // 遍历数组，得到每个同学姓名

        for (int i = 0; i < students.length; i++) {

            String name = students[i];

            // 打印同学姓名

            System.out.println("第" + (i + 1) + "个学生姓名：" + name);

        }

    }



    /**

     * 3.随机点名

     */

    public static String[] randomStudentName(String[] students) {
        // 通过随机索引从数组中获取姓名
        System.out.println("请输入你想抽取的人数：");
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] call = new String[n];
        int count = 0;
        while(count < n) {
            boolean flg = true;
            // 根据数组长度，获取随机索引
            int index = new Random().nextInt(students.length);
            for (int i = 0; i < call.length; i++) {
                if (call[i] == students[index]) {
                    flg = false;
                    break;
                }
            }
            if (flg) {
                call[count++] = students[index];
            }
        }

        // 返回随机点到的姓名

        return call;

    }



    public static void main(String[] args) {

        System.out.println("--------随机点名器--------");

        int num = 10;
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入班级人数：");
        num = scan.nextInt();

        // 创建一个可以存储多个同学姓名的容器（数组）

        String[] students = new String[num];

        /*

         * 1.存储全班同学姓名

         */

        addStudentName(students);

        /*

         * 2.总览全班同学姓名

         */

        printStudentName(students);

        /*

         * 3.随机点名

         */

        String[] randomName = randomStudentName(students);
        for(int i = 0; i < randomName.length; i++) {
            System.out.println("被点到名的同学是 :" + randomName[i]);
        }

    }

}